package fashionshop.gui.common.component;

import java.awt.Component;

import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

import fashionshop.gui.common.model.ModelData;

public abstract class GridCellRenderer<E extends ModelData> implements TableCellRenderer {

	public abstract Component render(DataGridView<E> grid, E model, Object value,
			boolean isSelected, boolean hasFocus, int row, int column);

	@SuppressWarnings("unchecked")
	@Override
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		DataGridView<E> grid = (DataGridView<E>)table;
		E model = grid.getModel(row);
		return render(grid, model, value, isSelected, hasFocus, row, column);
	}
	
}
